<extend name="Public/base" />

<block name="body">
  <!-- 标题栏 -->
  <div class="main-title">
    <h2>买送商品管理</h2>
  </div>
  

    <div class="cf">
      <div class="search-form fr cf">
          <input type="text" name="store" class="search-input w-260" value="{:I('store')}" placeholder="店铺名称">
          <a class="sch-btn" href="javascript:;" id="search" url="{:U()}"><i class="btn-search"></i></a>
      </div>
    </div>

  <!-- 数据列表 -->
  <div class="data-table table-striped">
    <table class="">
      <thead>
        <tr>
          <!-- <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th> -->
          <th>主商品</th>
          <th>最低购买数量</th>
          <th>赠品</th>
          <th>活动时间</th>
          <th>活动来源</th>
          <th>状态</th>
          <th width="140" class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>
      <notempty name="lists">
        <volist name="lists" id="vo">
          <tr class="status_trclass_{$vo.status}">
            <!-- <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td> -->
            <td>
              <eq name="vo.store_id" value="0">
                <a href="{:U('/Item/detail?id='.$vo['item_id'])}" target="_blank"><img src="{:get_image_thumb($vo['item_info']['thumb'], 60, 60)}" width="32"/></a>
                <a href="{:U('edit?id='.$vo['id'])}">{$vo.item_info.name}</a>
              <else />
                <img src="{:get_image_thumb($vo['item_info']['thumb'], 60, 60)}" width="32"/>{$vo.item_info.name}
              </eq>
            </td>
            <td>{$vo.min_num}</td>
            <td class="send_item_td">
              <volist name="vo.send_item" id="vv">
                <eq name="vo.store_id" value="0">
                <span><a href="{:U('/Item/detail?id='.$vv['id'])}" target="_blank"><img src="{:get_image_thumb($vv['item_info']['thumb'], 60, 60)}" width="32" title="{$vv.item_info.name} × {$vv.num}" alt="{$vv.item_info.name} × {$vv.num}"/></a>× {$vv.num}</span>
                <else />
                <span><img src="{:get_image_thumb($vv['item_info']['thumb'], 60, 60)}" width="32" title="{$vv.item_info.name} × {$vv.num}" alt="{$vv.item_info.name} × {$vv.num}"/> × {$vv.num}</span>
                </eq>
              </volist>
            </td>
            <td>
              {:time_format($vo['start_time'], 'Y-m-d')} ~ {:time_format($vo['expire_time'], 'Y-m-d')}

            </td>
            <td><gt name="member_id" value="0"><a href="{:U('Store/detail?member_id='.$member_id)}">{:store_name($vo['store_id'])}</a><else />{:store_name($vo['store_id'])}</gt></td>
            <td> <if condition="$vo['start_time'] gt NOW_TIME">
                <span class="text-danger">未开始</span>
                <else/>
                <if condition="$vo['expire_time'] gt NOW_TIME - 86400">
                    <span class="text-success">进行中</span>
                    <else/>
                    <span class="text-cancel">已过期</span>
                </if>
            </if></td>

            <td class="text-center">
              <eq name="vo.status" value="1">
                <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=0&ids='.$vo['id'])}" class="ajax-get">[禁用]</a><else /><span class="disabled">[禁用]</span></eq>
              <else/>
                <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=1&ids='.$vo['id'])}" class="ajax-get">[启用]</a><else /><span class="disabled">[启用]</span></eq>
              </eq>
              <eq name="vo.store_id" value="0"><a href="{:U('edit?id='.$vo['id'])}">[编辑]</a><else /><span class="disabled">[编辑]</span></eq>
              <eq name="vo.store_id" value="0"><a href="{:U('setStatus?status=-1&ids='.$vo['id'])}" class="confirm ajax-get">[删除]</a><else /><span class="disabled">[删除]</span></eq>
            </td>
          </tr>
        </volist>
        <else/>
        <td colspan="12" class="text-center"> aOh! 暂时还没有内容! </td>
      </notempty>
      </tbody>
    </table>

  </div>
  <div class="page">
    {$_page}
  </div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                if(url.indexOf('?')>0){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }

                window.location.href = url;
            });

            //回车自动提交
            $('.search-form').find('input').keyup(function(event){
                if(event.keyCode===13){
                    $("#search").click();
                }
            });

            //导航高亮
            highlight_subnav("{:U('index')}");
        });
    </script>
</block>
